package org.myorg;

import junit.framework.TestCase;

public class FGATest extends TestCase {
	
	public void testGa() {
		
/*		int geneLength = 1;
		int peopleNum = 20;
		double p_cross = 0.5;
		double p_mut = 0.5;
		int i_num = 10;
		
		double[] low = new double[1];
		double[] high = new double[1];
		
		low[0] = 0;
		high[0] = 2*3.1415926;
		       
		

		FGA.ga(geneLength, low, high, peopleNum, p_cross, p_mut, i_num, new FFunction());*/
		
		int geneLength = 1000;
		int peopleNum = 20;
		double p_cross = 0.5;
		double p_mut = 0.5;
		int i_num = 30000;
		
		double[] low = new double[1000];
		double[] high = new double[1000];
		
		for (int i = 0; i < 1000; i++) {
			low[i] = -100;
			high[i] = 100;
		}
		
		long st = System.currentTimeMillis();
		FGA.ga(geneLength, low, high, peopleNum, p_cross, p_mut, i_num, new FF1());
		long rt = System.currentTimeMillis() - st;
		System.out.println("run time is " + rt);
		
		FGene gene = FGA.best_people.getPersons()[FGA.best_people.getBest(new FF1())];
		RWF.wf(String.valueOf(gene.fitness),"/home/stanley/Documents/workspace/hadoop/hadoop-0.20.2/res/sres");
		
	}
}
